package cn.xopencode.recordservice.manager.pdroom;

import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.convert.pdroom.PowerDistributionRoomConvert;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomCreateDTO;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomPageDTO;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomQueryDTO;
import cn.xopencode.recordservice.rpc.pdroom.dto.PowerDistributionRoomUpdateDTO;
import cn.xopencode.recordservice.rpc.pdroom.vo.PowerDistributionRoomPageVO;
import cn.xopencode.recordservice.rpc.pdroom.vo.PowerDistributionRoomUpdateVO;
import cn.xopencode.recordservice.rpc.pdroom.vo.PowerDistributionRoomVO;
import cn.xopencode.recordservice.service.pdroom.PowerDistributionRoomService;
import cn.xopencode.recordservice.service.pdroom.bo.PowerDistributionRoomBO;
import cn.xopencode.recordservice.service.pdroom.bo.PowerDistributionRoomCreateBO;
import cn.xopencode.recordservice.service.pdroom.bo.PowerDistributionRoomUpdateBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 配电室
 */
@Service
public class PowerDistributionRoomManager {

    @Autowired
    private PowerDistributionRoomService powerDistributionRoomService;

    public Integer createPowerDistributionRoom(PowerDistributionRoomCreateDTO createDTO) {
        PowerDistributionRoomCreateBO bo = PowerDistributionRoomConvert.INSTANCE.convert(createDTO);
        Integer result = powerDistributionRoomService.createPowerDistributionRoom(bo, createDTO.getDeptIds());
        return result;
    }

    public List<PowerDistributionRoomVO> getPowerDistributionRoomList(String roomName){
        List<PowerDistributionRoomBO> roomBOList = powerDistributionRoomService.getPowerDistributionRoomList(roomName);
        return PowerDistributionRoomConvert.INSTANCE.convertList02(roomBOList);
    }

    public PageResult<PowerDistributionRoomPageVO> pagePowerDistributionRoom(PowerDistributionRoomPageDTO pageDTO) {
        PageResult<PowerDistributionRoomPageVO> boPageResult = powerDistributionRoomService.pagePowerDistributionRoom(PowerDistributionRoomConvert.INSTANCE.convert(pageDTO));
        return boPageResult;
    }

    public PowerDistributionRoomUpdateVO getPowerDistributionRoomById(String id){
        PowerDistributionRoomUpdateVO updateVO = powerDistributionRoomService.getPowerDistributionRoomById(id);
        return updateVO;
    }

    public Integer changeStatus(String roomId, Boolean flag){
        return powerDistributionRoomService.changeStatus(roomId, flag);
    }

    public Integer updatePowerDistributionRoom(PowerDistributionRoomUpdateDTO updateDTO) {
        PowerDistributionRoomUpdateBO bo = PowerDistributionRoomConvert.INSTANCE.convert(updateDTO);
        return powerDistributionRoomService.updatePowerDistributionRoom(bo, updateDTO.getDeptIds());
    }

    public Map<String, String> getLineNameByParam(PowerDistributionRoomQueryDTO queryDTO) {
        PowerDistributionRoomBO bo = PowerDistributionRoomConvert.INSTANCE.convert(queryDTO);
        return powerDistributionRoomService.getlineNameByParam(bo);
    }

    public List<PowerDistributionRoomVO> getPdroomNameListByType(Integer recordType){
        return PowerDistributionRoomConvert.INSTANCE.convertList02(powerDistributionRoomService.getPdroomNameListByType(recordType));
    }
}
